|
|
|
|
|
|
|
);
INSERT INTO BaseTable VALUES
('CUST03',
'Anchor, Smith, & Hocking',
'575.25',
'RETAIL',
'This is the last comment'
);
// now make a new table from the old one
SELECT * INTO CopyTable FROM BaseTable;
// select just some of the records
SELECT * INTO RetailTable FROM BaseTable
WHERE CustType='RETAIL';
// create a new summary table with fancy stuff added
SELECT CustType, SUM(CustBalance) AS Balance INTO SummaryTable
FROM BaseTable
GROUP BY CustType;
// show results
SELECT * FROM BaseTable;
SELECT * FROM CopyTable;
SELECT * FROM RetailTable;
SELECT * FROM SummaryTable;
// eof |
|
|
|
|
|
|
|
|
Figure 15.11.
Using GROUP BY and HAVING to summarize data. |
|
|
|
|
|